package com.example.pertecttime.base;

import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;

import com.example.pertecttime.tools.TUtil;
import com.example.pertecttime.tools.Ts;

/**
 * Created by 半生瓜 on 2017/7/12.
 */

public abstract class BaseActicvity<P extends BasePresenter, M extends BaseModel> extends AppCompatActivity implements View.OnClickListener{
    public Context c;
    public P presenter;
    public M model;
    public Ts t = new Ts(this);

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(this.getLayoutId());

        c = this;
        presenter = TUtil.getT(this, 0);
        model = TUtil.getT(this, 1);
        if (this instanceof Baseview) presenter.setVM(c, this, model);

        this.initview();
        this.initWindow();
        this.init();
    }

    void initWindow() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            View decorView = getWindow().getDecorView();
            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
            decorView.setSystemUiVisibility(option);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().setStatusBarColor(Color.TRANSPARENT);
            }
        }




    }
    @Override
    public void onClick(View view) {
        processClick(view);
    }

    protected void processClick(View view) {

    }
    public abstract int getLayoutId();

    public abstract void initview();

    public abstract void init();


}
